var date =  new Date();
var day = date.getDate();
var fx = localStorage.getItem('day')
$(function (){
    if (fx != day ){
        setTimeout(getDefer(),2000);
    }

})

function getDefer(){
    $.ajax({
        type:'post',
        url:'/getDeferByTime',
        data:{
            'num':30
        },
        dataType:'json',
        success:function (res){
            if (res.state == '200'){
                layer.confirm('30天欠费的学生表单，点击确定进行导出',function (index){
                    localStorage.setItem('day',day)
                    layer.open({
                        type:2,
                        title:'缓交30天到期学生信息',
                        content:'indexDefer.html',
                        area:['100%','100%']
                    })
                    layer.close(index);
                })
            }else {
                layer.msg('最近30天没有欠费学生')
            }
        },
        error:function (e){
            console.log('请求失败')
        }

    })
}

layui.use(['form','layer','jquery'], function () {
    var form = layui.form;
    var layer = layui.layer;
    var $ = layui.$;

    var user = JSON.parse(sessionStorage.getItem("user"))
    if(user.userName == null){
        $('#username').text('')
    }else{
        $('#username').text(user.userName)
    }
})


